package com.leetcode.merci.lc121;

/**
 * Created by bowen on 2017/7/25.
 */
public class Solution {
    public int maxProfit(int[] prices) {
        int l=prices.length;
        if(l==0) return 0;
        int max=0;
        int min=prices[0];
        for(int i=1;i<l;i++){
            min=min<prices[i]?min:prices[i];
            max=max>prices[i]-min?max:prices[i]-min;
        }
        return max;

    }
}